/*
 Peyote 3D 
 
 Copyright (c) 2010 Douglas J Lockamy
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:
 
 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 */
#include <windows.h>
#include <os_window.h>

int kWindowWidth = 640; /* window width */
int kWindowHeight = 480; /* window height */

static LONG WINAPI StaticWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
	switch (uMsg){
		case WM_CLOSE:
			return 0;
			break;
			
			break;	
	}		
	
	return DefWindowProc(hWnd, uMsg, wParam, lParam);
};

int os_window_init(int argc, char** argv)
{

	
	return 0;
};

//window variables
int wnd_handle;
///windows register window class
void Register(void)
{
	WNDCLASS cls = { CS_VREDRAW | CS_HREDRAW | CS_OWNDC, (WNDPROC)Window::StaticWindowProc,
		0, 0, wnd_Instance, 0, 0, (HBRUSH)GetStockObject(BLACK_BRUSH),
		0, "_APP_" };
	RegisterClass(&cls);
};


//window functions
int os_createWindow(const char *name,struct rect r,int flags)
{
	wnd_handle = (int)CreateWindowEx(WS_EX_APPWINDOW,
		"app_name", "_APP_,"WS_BORDER | WS_DLGFRAME | WS_CLIPSIBLINGS,
		0, 0,
		kWindowWidth,kWindowHeight,
		0, 0, wnd_Instance, 0);
	
	Register();
	
	SetWindowPos((HWND)wnd_handle.ivalue, 0, 199, 
				 199,199+kWindowWidt, 199+kWindowHeight, SWP_SHOWWINDOW);
//	
	ShowWindow((HWND)wnd_handle.ivalue, SW_SHOWNORMAL);
	SetCapture((HWND)wnd_handle.ivalue);
	
	SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);	
	
	return -1;
};

int os_deleteWindow(int id)
{
	return -1;
};

int os_moveWindow(struct rect newRect)
{
	return -1;
};

int os_resizeWindow(struct rect newRect)
{
	return -1;
};

int os_statInput(void)
{
	return -1;
};

int os_update(void)
{
	return -1;
};

void os_keyboard(unsigned char key, int x, int y)
{
	switch (key) {
		case 27:    /* ESC key */
		case 'Q':   /* Q|q keys */
		case 'q':
			exit(0);
			break;
		default:
			break;
	}	
};

void os_mouse(unsigned char key, int x, int y)
{
	
};

void os_touch(unsigned char key, int x, int y)
{
	
};

